package com.czwx.bee.business.manager.modular.statistics.model;

import com.czwx.bee.business.manager.modular.cloanuser.model.CloanUser;
import com.czwx.bee.business.manager.modular.cloanuser.model.query.CloanUserQuery;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author:wiki
 * @Date:Create in 2018/7/4 0004 上午 11:45
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value="BizDataModel",description="业务数据对象")
public class BizDataModel {

    @ApiModelProperty(value="日期")
    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
    private Date date;

    @ApiModelProperty(value="注册量")
    private Long registNum ;

    @ApiModelProperty(value="申请量")
    private Long applyNum ;

    @ApiModelProperty(value="通过率")
    private String passPercent ;

    @ApiModelProperty(value="放款数")
    private Long loanNum ;

    @ApiModelProperty(value="放款总金额")
    private Double loanMoney;

    @ApiModelProperty(value="应还款笔数")
    private Long shouldRepayNum;

    @ApiModelProperty(value="应还款金额")
    private Double shouldRepayMoney;

    @ApiModelProperty(value="还款笔数")
    private Long repaymentNum ;

    @ApiModelProperty(value="还款总额")
    private Long repaymentMoney ;

    @ApiModelProperty(value="逾期总额")
    private Long overdueMoney ;

    @ApiModelProperty(value="逾期笔数")
    private Long overdueNum ;

    @ApiModelProperty(value="逾期率")
    private String overduePercent;

    public String getPassPercent(){
            if(applyNum>0&&registNum>0){
                Double passPercent=Double.valueOf(applyNum)/Double.valueOf(registNum)*100;
                BigDecimal bg = new BigDecimal(passPercent);
                passPercent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
                return this.passPercent=passPercent+"%";
            }
            else {
                return "0%";
            }

    }

    public String getoverduePercent(){
        if(overdueNum>0&&shouldRepayNum>0){
            Double passPercent=Double.valueOf(overdueNum)/Double.valueOf(shouldRepayNum)*100;
            BigDecimal bg = new BigDecimal(passPercent);
            passPercent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
            return this.overduePercent=passPercent+"%";
        }
        else {
            return "0%";
        }
    }
}
